﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.nickro.project.BulkLoad.utils {

    public class SmartURL {

        public var rawString:String;
        public var port:int;
        public var path:String;
        public var queryObject:Object;
        public var queryString:String;
        public var host:String;
        public var queryLength:int = 0;
        public var fileName:String;
        public var protocol:String;

        public function SmartURL(_arg1:String){
            var _local4:String;
            var _local5:String;
            var _local6:String;
            super();
            this.rawString = _arg1;
            var _local2:RegExp = /((?P<protocol>[a-zA-Z]+: \/\/)   (?P<host>[^:\/]*) (:(?P<port>\d+))?)?  (?P<path>[^?]*)? ((?P<query>.*))? /x;
            var _local3:* = _local2.exec(_arg1);
            if (_local3){
                this.protocol = (Boolean(_local3.protocol)) ? _local3.protocol : "http://";
                this.protocol = this.protocol.substr(0, this.protocol.indexOf("://"));
                this.host = ((_local3.host) || (null));
                this.port = (_local3.port) ? int(_local3.port) : 80;
                this.path = _local3.path;
                this.fileName = this.path.substring(this.path.lastIndexOf("/"), this.path.lastIndexOf("."));
                this.queryString = _local3.query;
                if (this.queryString){
                    this.queryObject = {};
                    this.queryString = this.queryString.substr(1);
                    for each (_local6 in this.queryString.split("&")) {
                        _local5 = _local6.split("=")[0];
                        _local4 = _local6.split("=")[1];
                        this.queryObject[_local5] = _local4;
                        this.queryLength++;
                    };
                };
            } else {
                trace("no match");
            };
        }
        public function toString(... _args):String{
            if ((((_args.length > 0)) && ((_args[0] == true)))){
                return (((((((((((("[URL] rawString :" + this.rawString) + ", protocol: ") + this.protocol) + ", port: ") + this.port) + ", host: ") + this.host) + ", path: ") + this.path) + ". queryLength: ") + this.queryLength));
            };
            return (this.rawString);
        }

    }
}//package org.nickro.project.BulkLoad.utils 
